﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ProggersWTC.Model;

namespace ProggersWTC.Views.SpelerViews
{
    /// <summary>
    /// Interaction logic for SpelerPage.xaml
    /// </summary>
    public partial class SpelerPage : Page
    {
        public SpelerPage()
        {
            InitializeComponent();
            List<Spelers> spelers = Queries.GetAllSpelersOrdered();
            spelersDataGrid.ItemsSource = spelers;
        }

        public Spelers GetSelectedSpeler()
        {
            //spelersDataGrid
            object selected = spelersDataGrid.SelectedItem;
            if (selected != null)
            {
                return (Spelers)selected;
            }
            return null;
        }

        public void AddSpeler()
        {
            SpelerActionWindow toevoegenWindow = new SpelerActionWindow();
            toevoegenWindow.ShowDialog();
        }

        public void EditSpeler()
        {
            Spelers speler = GetSelectedSpeler();
            if (speler != null)
            {
                SpelerActionWindow bewerkenWindow = new SpelerActionWindow(speler);
                bewerkenWindow.ShowDialog();
            }
            else
            {
                MessageHandler.ShowWarning("Geen speler geselecteerd");
            }
        }

        public void RemoveSpeler()
        {

        }
    }
}
